package lion.framework.core.db;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

public class SQLJoin {

	private List<String> pices = new ArrayList<>();

	public List<String> sort = new ArrayList<>();

	public void add(String pice) {

		if (StringUtils.isBlank(pice)) { return; }
		this.pices.add(pice);
	}

	public void addSort(String col, String order) {

		if (StringUtils.isBlank(col)) { return; }
		this.sort.add(col + (!StringUtils.equals(order, "asc") ? " desc" : " asc"));
	}

	@Override
	public String toString() {

		StringBuilder sb = new StringBuilder();
		sb.append(StringUtils.join(this.pices, " and "));
		if (!this.sort.isEmpty()) {
			sb.append(" order by ");
			sb.append(StringUtils.join(this.sort, ","));
		}
		return sb.toString();
	}
}

/*
 * Location: D:\Maven\repo\lion\lion-core\0.7.2.1\lion-core-0.7.2.1.jar
 * Qualified Name: lion.framework.core.db.SQLJoin JD-Core Version: 0.6.2
 */